﻿// -----------------------------------------------------------------------
// <copyright file="PageInfoConfig.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace NetFramework.Router.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Serialization;
    using NetFramework.Configuration;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    [Serializable]
    [XmlRoot("PageInfoConfig")]
    [ConfigFile("Configs/Resource/Page/*.config")]
    public class PageInfoConfig
    {
        [XmlArray("Pages")]
        [XmlArrayItem("page")]
        public PageInfo[] Pages { get; set; }

        /// <summary>
        /// 获取页面名称获取页面配置信息
        /// </summary>
        /// <param name="pageName"></param>
        /// <returns></returns>
        public PageInfo GetPageInfo(string pageName)
        {
            PageInfo pageInfo = null;

            if (Pages != null)
            {
                foreach (PageInfo page in Pages)
                {
                    if (page.PageName == pageName)
                    {
                        pageInfo = page;
                        break;
                    }
                }
            }

            return pageInfo;
        }
    }
}
